package com.laogao.controller;

import com.laogao.common.R;
import com.laogao.dto.ExamDto;
import com.laogao.service.ExamService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exams")
@RequiredArgsConstructor
public class ExamController {

    private final ExamService examService;

    @PostMapping("/cascade")
    public R saveExamWithAll(@RequestBody @Validated ExamDto examDto) {
        examService.saveExamWithAll(examDto, examDto.getQuestionCount(), examDto.getOptionCountPerQuestion());
        return R.ok("保存成功");
    }
}